<?php

namespace App\Http\Controllers\Mobile;


use App\Logics\SiteLogic;
use App\Models\SiteAdv;
use App\Models\SiteInfo;
use Illuminate\Support\Facades\Config;

class SiteController extends BaseController
{
    // 一般操作
    public function initialize()
    {
        parent::initialize();
    }

    // 当前服务器域名
    public function cdn()
    {
        $domain = Config::get('site.cdnHost');
        $domain = substr($domain, -1) == '/' ? substr($domain, 0, -1) : $domain;

        return $this->success(['domain' => $domain]);
    }

    // 广告
    public function adv()
    {
        $lists = (new SiteLogic())->adv();

        return $this->success($lists);
    }

    // 用户协议
    public function service()
    {
        return $this->info(1);
    }

    // 隐私协议
    public function privacy()
    {
        return $this->info(2);
    }

    // 联系我们
    public function contact()
    {
        return $this->info(3);
    }

    // 帮助中心
    public function help()
    {
        return $this->info(4);
    }

    // 收益规则
    public function incomeRule()
    {
        return $this->info(5);
    }

    // 配置
    public function config()
    {
        $config = (new SiteLogic())->config();

        return $this->success($config);
    }

    // 版本号：小程序
    public function miniVersion()
    {
        return $this->version('mini');
    }

    // 版本号：ios
    public function iosVersion()
    {
        return $this->version('ios');
    }

    // 版本号：安卓
    public function androidVersion()
    {
        return $this->version('android');
    }


    #############################################################################################
    // 获取系统设置的文章
    protected function info($id)
    {
        $info = (new SiteLogic())->info($id);

        return $this->success($info);
    }

    // 版本号
    protected function version($platform)
    {
        $info = (new SiteLogic())->version($platform);

        return $this->success($info);
    }

}


